<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script>
        function Pet(nickname, age) {
            this.nickname = nickname;
            this.age = age;
        }

        Pet.prototype.getNickName = function () {
            return this.nickname;
        };

        Pet.prototype.getAge = function () {
            return this.age;
        };

        function Dog(nickname, age, color) {
            Pet.call(this, nickname, age);
            this.color = color;
        }

        Dog.prototype = Object.create(Pet.prototype);
        Dog.prototype.constructor = Dog;

        Dog.prototype.getColor = function () {
            return this.color;
        };

        let dog = new Dog('旺财', 3, '黄色');

        console.log(`宠物昵称:${dog.getNickName()}`);
        console.log(`宠物年龄:${dog.getAge()}`);
        console.log(`宠物颜色:${dog.getColor()}`);
    </script>
    </body>
</html>